package com.xjscrm.console.web.group;

import com.xjscrm.console.param.BaseDto;
import com.xjscrm.console.param.group.*;
import com.xjscrm.console.service.customer.group.WwGroupBatchService;
import com.xjscrm.console.service.customer.group.WwGroupService;
import com.xjscrm.console.vo.SyncGroupJobVo;
import com.xjscrm.console.vo.WwGroupMemberVo;
import com.xjscrm.console.vo.WwGroupVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@Api(value = "客户群管理", tags = "客户群管理")
@RestController
@RequestMapping(value = "/wwGroup")
public class WwGroupController {


    @Autowired
    private WwGroupService wwGroupService;

    @Autowired
    private WwGroupBatchService wwGroupBatchService;

    @ApiOperation(value = "查询客户群列表", notes = "查询客户群列表",response = WwGroupVo.class)
    @PostMapping(value ="/getWwGroupList" )
    public Object getWwGroupList(@RequestBody WwGroupQuery wwGroupQuery)throws Exception{
        return wwGroupService.getWwGroupList(wwGroupQuery);
    }

    @ApiOperation(value = "查询客户群详情", notes = "查询客户群详情",response = WwGroupVo.class)
    @PostMapping(value ="/getWwGroupDetail" )
   public Object getWwGroupDetail(@RequestBody WwGroupDto wwGroupDto)throws Exception{
        return wwGroupService.getWwGroupDetail(wwGroupDto);
   }

    @ApiOperation(value = "批量设置群成员是否能修改群名设置", notes = "批量设置群成员是否能修改群名设置",response = Boolean.class)
    @PostMapping(value ="/batchGroupMemberUpdateGroupName" )
  public Object batchGroupMemberUpdateGroupName(@RequestBody WwGroupDto wwGroupDto)throws Exception{
        wwGroupBatchService.batchGroupMemberUpdateGroupName(wwGroupDto);
        return true;
  }

    @ApiOperation(value = "批量改群名", notes = "批量改群名",response = Boolean.class)
    @PostMapping(value ="/batchUpdateGroupName" )
    public Object batchUpdateGroupName(@RequestBody BatchUpdateGroupNameDto batchUpdateGroupNameDto)throws Exception{
        wwGroupBatchService.batchUpdateGroupName(batchUpdateGroupNameDto);
        return true;
    }

    @ApiOperation(value = "批量删除客户群", notes = "批量删除客户群",response = Boolean.class)
    @PostMapping(value ="/batchdeleGroup" )
    public  Object batchdeleGroup(@RequestBody WwGroupDto wwGroupDto)throws Exception{
        wwGroupBatchService.batchdeleGroup(wwGroupDto);
        return true;
    }

    @ApiOperation(value = "查询群成员列表", notes = "查询群成员列表",response = WwGroupMemberVo.class)
    @PostMapping(value ="/getGroupMemberList" )
    public Object getGroupMemberList(@RequestBody WwGroupMemberQuery wwGroupMemberQuery)throws Exception{
        return wwGroupService.getGroupMemberList(wwGroupMemberQuery);
  }

    @ApiOperation(value = "新增客户群设置", notes = "新增客户群设置",response = Boolean.class)
    @PostMapping(value ="/addWwGroupConfig" )
  public Object addWwGroupConfig(@RequestBody WwGroupConfigDto wwGroupConfigDto)throws Exception{
          wwGroupService.addWwGroupConfig(wwGroupConfigDto);
          return true;
  }

    @ApiOperation(value = "查询客户群设置", notes = "查询客户群设置",response = String.class)
    @PostMapping(value ="/getWwGroupConfig" )
  public Object getWwGroupConfig(@RequestBody BaseDto baseDto)throws Exception{
        return wwGroupService.getWwGroupConfig(baseDto);
  }

    @ApiOperation(value = "导出群信息", notes = "导出群信息",response = Boolean.class)
    @PostMapping(value ="/exportWwGroup" )
    public void exportWwGroup(@RequestBody WwGroupQuery wwGroupQuery, HttpServletResponse response)throws Exception{
        wwGroupService.exportWwGroup(wwGroupQuery,response);
  }

    @ApiOperation(value = "同步客户群", notes = "同步客户群",response = Boolean.class)
    @PostMapping(value ="/syncWwGroup" )
  public Object syncWwGroup(@RequestBody SyncWwGroupDto syncWwGroupDto)throws Exception{
        wwGroupService.syncWwGroup(syncWwGroupDto);
        return true;
  }


    @ApiOperation(value = "批量同步客户群", notes = "批量同步客户群", response = Boolean.class)
    @PostMapping(value = "/batchSyncWwGroup")
    public Object batchSyncWwGroup(@RequestBody BatchSyncWwGroupDto batchSyncWwGroupDto) throws Exception {
        wwGroupService.batchSyncWwGroup(batchSyncWwGroupDto);
        return true;
    }

    @ApiOperation(value = "查询同步客户群任务列表", notes = "查询同步客户群任务列表", response = SyncGroupJobVo.class)
    @PostMapping(value = "/getSyncGroupList")
    public Object getSyncGroupList(@RequestBody SyncWwGroupQuery syncWwGroupQuery) throws Exception {
        return wwGroupService.getSyncGroupList(syncWwGroupQuery);
    }


    @ApiOperation(value = "删除同步客户群任务任务", notes = "删除同步客户群任务任务", response = Boolean.class)
    @PostMapping(value = "/delSyncGroup")
    public Object delSyncGroup(@RequestBody DelSyncGroupDto delSyncGroupDto) throws Exception {
        wwGroupService.delSyncGroup(delSyncGroupDto);
        return true;
    }


    @ApiOperation(value = "同步客户群成员", notes = "同步客户群成员",response = Boolean.class)
    @PostMapping(value ="/syncWwGroupMerber" )
  public Object syncWwGroupMerber(@RequestBody SyncWwGroupMemberDto syncWwGroupMemberDto)throws Exception{
        wwGroupService.syncWwGroupMerber(syncWwGroupMemberDto);
             return true;
  }

    @ApiOperation(value = "批量退群", notes = "批量退群",response = Boolean.class)
    @PostMapping(value ="/batchQuitWwGroup" )
  public Object batchQuitWwGroup(@RequestBody WwGroupDto wwGroupDto)throws Exception{
        wwGroupBatchService.batchQuitWwGroup(wwGroupDto);
        return true;
  }

    @ApiOperation(value = "转让群主", notes = "转让群主",response = Boolean.class)
    @PostMapping(value ="/transferGroupAdmin" )
  public Object transferGroupAdmin(@RequestBody TransferGroupAdminDto transferGroupAdminDto)throws Exception{
        wwGroupBatchService.transferGroupAdmin(transferGroupAdminDto);
        return true;
  }


    @ApiOperation(value = "新增群管理", notes = "新增群管理",response = Boolean.class)
    @PostMapping(value ="/addGroupManager" )
  public Object addGroupManager(@RequestBody AddGroupManagerDto addGroupManagerDto)throws Exception{
        wwGroupBatchService.addGroupManager(addGroupManagerDto);
        return true;
  }

//    @ApiOperation(value = "获取接收机器人列表", notes = "获取接收机器人列表",response = WwDeviceVo.class)
//    @PostMapping(value ="/getReceiveDeviceList" )
//  public Object getReceiveDeviceList(@RequestBody TransferableGroupDto transferableGroupDto)throws Exception{
//        return   wwGroupService.getReceiveDeviceList(transferableGroupDto);
//
//  }

    @ApiOperation(value = "获取可转让群聊", notes = "获取可转让群聊",response = WwGroupVo.class)
    @PostMapping(value ="/getTransferableGroup" )
  public Object getTransferableGroup(@RequestBody TransferableGroupDto transferableGroupDto)throws Exception{
        return  wwGroupService.getTransferableGroup(transferableGroupDto);
  }


    @ApiOperation(value = "获取可设置的群", notes = "获取可设置的群",response = WwGroupVo.class)
    @PostMapping(value ="/getManagerableGroup" )
  public Object getManagerableGroup(@RequestBody ManagerableGroupDto managerableGroupDto)throws Exception{
        return  wwGroupService.getManagerableGroup(managerableGroupDto);
  }

}
